/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#include <xmmintrin.h>
#include "hhdMathConfig.h"

namespace hhd
{
	class HVector3;

	/**
	* This class is used for storing rotation. This calls represents unit Quaternions useful for
	* certain operations but needs to be read into a matrix for rendering. This class is optimized
	* for certain operations via SSE intrinsics.
	*
	* @see HMatrix4x4
	* @see HVector3
	*/
	class __declspec( align( 16 ) ) HQuaternion
	{
	public:
		//Constructors

		/**
		* Default constructor creates and identity rotation Quaternion.
		*/
		HQuaternion(void);
		~HQuaternion(void);

		/**
		* Will create this HQuaternion from another.
		*/
		HQuaternion( const HQuaternion& other );

		/**
		* Will construct the Quaternion from the four floats passed in.
		* NOTE: This constructor should only be called if you know exactly what
		* you are doing, and then you should ask yourself why you are doing this.
		*
		* @param w The w component of the HQuaternion.
		* @param x The x component of the HQuaternion.
		* @param y The y component of the HQuaternion.
		* @param z The z component of the HQuaternion.
		*/
		HQuaternion( hfloat32 w, hfloat32 x, hfloat32 y, hfloat32 z );

		/**
		* This will create a Quaternion from an axis vector and a scalar angle.
		* 
		* @param v The axis HVector that with be used to construct the HQuaternion.
		* @param angle The angle that will be used to constuct the HQuaternion. 
		* NOTE: it is assumed to be a unit HVector3.
		*/
		HQuaternion( const HVector3& axis, hfloat32 angle );

		//Operators

		//Constant static members
		const static HQuaternion& identity;

	private:
		/** { z, y, x, w } */
		__m128 _data;
		//w = cos(theta/2)
		//v = sine(theta/2)r
	};
}
